from botcore import * from time import sleep from random import randrange F4 = 349 C5 = 523 def note(freq, duration): spkr.pitch(freq) sleep(duration) spkr.off() sleep(0.05) while True: if buttons.was_pressed(0): break motors.enable(True) # Move forward 2 feet motors.run(LEFT, 80) motors.run(RIGHT, 80) sleep(2) # Spin 360 degrees motors.run(LEFT, 30) motors.run(RIGHT, -30) count = 0 while count < 38: count = count + 1 f = randrange(100, 1000) spkr.pitch(f) sleep(0.1) spkr.off() motors.enable(False) # Fanfare sleep(0.5) note(F4, 0.4) sleep(0.2) note(F4, 0.1) note(F4, 0.1) note(C5, 0.8)